package morenoapp.components.thinkgraph.model;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import morenoapp.components.thinkgraph.PiccoloGraph;
import morenoapp.model.data.MorenoQuestionFace;
import morenoapp.util.I18N;

/**
 *
 * @author dmitry.mamonov
 */
public class DisplayFilter {
    PiccoloGraph graph;

    String filterName = I18N.get("label.main_view");
    boolean accurateDraw = true; //canvas
    boolean displayTooltips = false; //respondent
    boolean displaySex = true;//respondent
    boolean displayMetrics = true;
    boolean displayAnalytics = true; //to dev null
    boolean displayCorrectionVectors = true;
    /**
     * Отображать имена респондентов вместо номеров.
     */
    boolean displayNames = false;
    /**
     * Шаг с которым отрисовываются кольца социограммы.
     */
    int ringsStep = 100;
    Set<DisplayFilterListener> listeners = new HashSet();
    Map<MorenoQuestionFace, DisplayMode> quesionDisplayModeMap = new HashMap();

    public void addDisplayFilterLisneter(DisplayFilterListener _listener) {
        listeners.add(_listener);
    }

    public PiccoloGraph getGraph() {
        return graph;
    }

    public void setGraph(PiccoloGraph graph) {
        this.graph = graph;
    }

    public String getFilterName() {
        return filterName;
    }

    public void setFilterName(String filterName) {
        this.filterName = filterName;
    }

    private void fireDisplayFilterChanged() {
        for (DisplayFilterListener listener : listeners) {
            listener.onDisplayFilterChanged();
        }
    }

    public int getRingStep() {
        return ringsStep;
    }

    public void setRingStep(int ringStep) {
        this.ringsStep = ringStep;
        fireDisplayFilterChanged();
    }

    public boolean isAccurateDraw() {
        return accurateDraw;
    }

    public void setAccurateDraw(boolean accurateDraw) {
        this.accurateDraw = accurateDraw;
        fireDisplayFilterChanged();
    }

    public boolean isDisplayTooltips() {
        return displayTooltips;
    }

    public void setDisplayTooltips(boolean displayTooltips) {
        this.displayTooltips = displayTooltips;
        fireDisplayFilterChanged();
    }

    public boolean isDisplayAnalytics() {
        return displayAnalytics;
    }

    public void setDisplayAnalytics(boolean displayAnalytics) {
        this.displayAnalytics = displayAnalytics;
        fireDisplayFilterChanged();
    }

    public boolean isDisplayCorrectionVectors() {
        return displayCorrectionVectors;
    }

    public void setDisplayCorrectionVectors(boolean displayCorrectionVectors) {
        this.displayCorrectionVectors = displayCorrectionVectors;
        fireDisplayFilterChanged();
    }

    public boolean isDisplayMetrics() {
        return displayMetrics;
    }

    public void setDisplayMetrics(boolean displayMetrics) {
        this.displayMetrics = displayMetrics;
        fireDisplayFilterChanged();
    }

    public boolean isDisplayNames() {
        return displayNames;
    }

    public void setDisplayNames(boolean displayNames) {
        this.displayNames = displayNames;
        fireDisplayFilterChanged();
    }

    public boolean isDisplaySex() {
        return displaySex;
    }

    public void setDisplaySex(boolean displaySex) {
        this.displaySex = displaySex;
        fireDisplayFilterChanged();
    }

    public void setDisplayModeForQuestion(MorenoQuestionFace _question, DisplayMode _displayMode) {
        quesionDisplayModeMap.put(_question, _displayMode);
        fireDisplayFilterChanged();
    }

    public DisplayMode getDisplayModeForQuestion(MorenoQuestionFace _question) {
        DisplayMode displayMode = quesionDisplayModeMap.get(_question);
        return displayMode != null ? displayMode : DisplayMode.Normal;
    }
}
